using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using CoVuaCtrl;

namespace CoVua
{
    public partial class uctrlQuanCo : UserControl
    {
        public uctrlQuanCo()
        {
            InitializeComponent();
            
        }

        protected Bitmap _picQuanCo;
        protected QuanCo _quanCo;

        [Browsable(true)]
        public Bitmap picQuanCo
        {
            get
            {
                return _picQuanCo;
            }
            set
            {                
                _picQuanCo = value;
                _picQuanCo.MakeTransparent(_picQuanCo.GetPixel(0, 0));                
            }
        }
        public QuanCo quanCo
        {
            get
            {
                return _quanCo;
            }
            set
            {
                _quanCo = value;
            }
        }
        private void uctrlQuanCo_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            if (picQuanCo != null)
            {
                int width = picQuanCo.Width;
                int height = picQuanCo.Height;
                int x0 = (Width - width) / 2;
                int y0 = (Height - height) / 2;
                g.DrawImage(picQuanCo, x0, y0, width, height);
            }
            if (bHover)
            {
                g.DrawRectangle(new Pen(Color.Red, 1), 4, 4, this.Width - 10, this.Height - 10);
            }
        }

        private void uctrlQuanCo_Load(object sender, EventArgs e)
        {
            
        }
     
        protected bool bHover;
        private void uctrlQuanCo_MouseHover(object sender, EventArgs e)
        {
            
        }

        private void uctrlQuanCo_MouseLeave(object sender, EventArgs e)
        {
            bHover = false;
            Invalidate();
        }

        private void uctrlQuanCo_MouseEnter(object sender, EventArgs e)
        {
            bHover = true;
            Invalidate();
        }
    }
}
